<?php

class Ad extends AppModel {
  public $name = 'Ad';
  public $belongsTo = array('Company'=>array(
      'className'=> 'Company',
      'foreignKey'=>'company_id',
      'type' =>'inner'
 ));
  public $hasMany = array('AdPhotos'=> array('className'=>'AdPhotos', 'foreign_key'=>'ad_id', 'dependent'=>true));

  public $validate = array(
      'Ad.company_id' => array(
          'name' => 'notEmpty',
          'message'=>'Company is required'
      ),
       'start_date' => array(
          'formatRule' => array(
              'rule' => array('validDateFormat'),
              'allowEmpty' => false,
              'message' => 'Enter a valid Start date (mm/dd/yyyy)'
          ),
          'dateRestrictionRule' => array(
              'rule' => array('dateBefore', 'end_date'),
              'message' => 'Start date must be before End date'
      )),
      'end_date' => array(
          'rule' => array('validDateFormat'),
          'allowEmpty' => false,
          'message' => 'Enter a valid End date (mm/dd/yyyy)'
      )
  );
   //http://book.cakephp.org/1.3/view/1042/belongsTo
  
}

?>
